package mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import pojo.User;

import java.util.List;

@Repository
public interface UserMapper {

    @Select("select * from user")
    List<User> selectAll();

    @Delete("delete from user where userid=#{userid}")
    int deleteById(String userid);//int代表删除行数

    List<User> selectByConditions(User user);

    @Update("update user set username=#{username},password=#{password}, gender=#{gender}, address=#{address}, email=#{email}, phone=#{phone},postcode=#{postcode},state=#{state} where userid=#{userid}")
    int update(User user);

    @Insert("insert into user values(#{userid},#{username},#{password},#{gender},#{address},#{email},#{phone},#{postcode},#{state})")
    int insert(User user);

    @Select("select * from user where userid=#{userid}")
    User selectById(String userid);

}
